package com.qs.order.message;

import com.qs.order.dto.OrderDto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * @Desc:  接收端
 * @author: jianfeng
 * @Time: 2019/9/24 9:13
 */
@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {

//    @StreamListener(StreamClient.INPUT)
//    public void process(Object message){
//        log.info("StreamReceiver：{}",message);
//    }

    /**
    * @Desc:  接受orderDto对象，消息
    * @author: jianfeng
    * @Time: 2019/9/24 9:28
    * @param message
    * @return void
    */
    @StreamListener(StreamClient.INPUT)
    @SendTo(StreamClient.INPUT2)//返回给发送端mq消息
    public String process(OrderDto message){
        log.info("StreamReceiver：{}",message);
        return "received.";
    }

    @StreamListener(StreamClient.INPUT2)
    public void process2(String message){
        log.info("StreamReceiver2：{}",message);
    }

}
